// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.designer.ui.process.models;

import org.dengues.core.process.CompElement;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;

/**
 * qzhang class global comment. Detailled comment <br/>
 * 
 * 
 */
public class CompNote extends CompElement {

    public static final String PROP_TEXT = "pro_text"; //$NON-NLS-1$

    public static final String PROP_LOC = "pro_loc"; //$NON-NLS-1$

    public static final String PROP_SIZE = "pro_size"; //$NON-NLS-1$

    public static final String PROP_OPAQ = "pro_opaque"; //$NON-NLS-1$

    private CompProcess compProcess;

    private String text;

    private Point location = new Point(0, 0);

    private Dimension size = new Dimension(0, 0);

    private boolean isOpaque;

    /**
     * 
     */
    private static final long serialVersionUID = 112121213123412L;

    /*
     * (non-Javadoc)
     * 
     * @see org.dengues.designer.ui.gef.nodes.Element#getElementName()
     */
    @Override
    public String getCompName() {
        return "Note";
    }

    /**
     * Getter for location.
     * 
     * @return the location
     */
    @Override
    public Point getLocation() {
        return this.location;
    }

    /**
     * Sets the location.
     * 
     * @param location the location to set
     */
    public void setLocation(Point location) {
        this.location = location;
        fireStructureChange(PROP_LOC, this.location);
    }

    /**
     * Getter for size.
     * 
     * @return the size
     */
    @Override
    public Dimension getSize() {
        return this.size;
    }

    /**
     * Sets the size.
     * 
     * @param size the size to set
     */
    public void setSize(Dimension size) {
        this.size = size;
        fireStructureChange(PROP_SIZE, this.size);
    }

    /**
     * Getter for text.
     * 
     * @return the text
     */
    public String getText() {
        return this.text;
    }

    /**
     * Sets the text.
     * 
     * @param text the text to set
     */
    public void setText(String text) {
        this.text = text;
        fireStructureChange(PROP_TEXT, this.text);
    }

    /**
     * Getter for isOpaque.
     * 
     * @return the isOpaque
     */
    public boolean isOpaque() {
        return this.isOpaque;
    }

    /**
     * Sets the isOpaque.
     * 
     * @param isOpaque the isOpaque to set
     */
    public void setOpaque(boolean isOpaque) {
        this.isOpaque = isOpaque;
        fireStructureChange(PROP_OPAQ, this.isOpaque);
    }

    /**
     * Getter for compProcess.
     * 
     * @return the compProcess
     */
    @Override
    public CompProcess getCompProcess() {
        return this.compProcess;
    }

    /**
     * Sets the compProcess.
     * 
     * @param compProcess the compProcess to set
     */
    public void setCompProcess(CompProcess compProcess) {
        this.compProcess = compProcess;
    }

    @Override
    public CompNote clone() {
        CompNote note = null;
        try {
            note = (CompNote) super.clone();
            note.setLocation(getLocation().getCopy());
            note.setSize(getSize().getCopy());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return note;
    }
}
